package com.xuecheng.content.contrller;


import com.xuecheng.content.model.dto.CourseTecherDto;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.iml.CourseTecherServiceIml;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@Slf4j
@Api(value = "教师信息编辑接口",tags = "教师信息编辑接口")
public class CourseTecherController {

    private final CourseTecherServiceIml courseTecherServiceIml;


    @ApiOperation("查询教师信息")
    @GetMapping("/courseTeacher/list/{id}")
    public List<CourseTeacher> queryCourseTecher(@PathVariable Long id){
        log.info("查询教师信息：{}",id);
        return courseTecherServiceIml.queryCourseTecher(id);
    }

    @ApiOperation("新增教师信息")
    @PostMapping("/courseTeacher")
    public CourseTeacher saveCourseTecher(@RequestBody CourseTecherDto courseTecherDto){
        log.info("新增教师信息：{}",courseTecherDto);
        return courseTecherServiceIml.saveCourseTecher(courseTecherDto);
    }


    @ApiOperation("修改教师信息")
    @PutMapping("/courseTeacher")
    public CourseTeacher updateCourseTecher(@RequestBody CourseTecherDto courseTecherDto){
        log.info("修改教师信息：{}",courseTecherDto);
        return courseTecherServiceIml.updateCourseTecher(courseTecherDto);
    }


    @ApiOperation("删除教师信息")
    @DeleteMapping("/courseTeacher/course/{courseId}/{id}")
    public void deleteCourseTecher(@PathVariable Long courseId,@PathVariable  Long id){
        log.info("删除教师信息：课程id{},教师id",courseId,id);
        courseTecherServiceIml.deleteCourseTecher(courseId,id);
    }
}
